import request from '../utils/request'

// 获取频道
const getUserChannelAPI = () => request({
  url: '/v1_0/user/channels'

})
// 获取列表
const getArticelListAPI = ({ channelId, timestamp = (new Date()).getTime() }) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp
    }
  })
}
// 文章-不感兴趣

const articleDislikeAPI = ({ target }) => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: target
    }

  })
}

// 文章-举报
const articleReportsAPI = ({ target, type, remark }) => {
  return request({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target: target,
      type: type,
      remark: type === '0' ? remark : remark || null
    }

  })
}

// 首页-频道-获取所有
const getAllChannelListAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/channels'
  })
}

// 首页-修改（更新）用户 选择的频道
const updateUserChannelListAPI = ({ channels }) => {
  return request({
    method: 'PUT',
    url: '/v1_0/user/channels',
    data: {
      channels
    }
  })
}

export {
  getUserChannelAPI,
  getArticelListAPI,
  articleDislikeAPI,
  articleReportsAPI,
  getAllChannelListAPI,
  updateUserChannelListAPI
}
